Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opt_reduce: keep at least one input to $reduce_or/and cells #4614

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

georgerennie
Copy link
Collaborator

When all inputs to a $reduce_or (resp. $reduce_and) are 0 (resp 1), opt_reduce would remove them all leaving a zero width input to the cell. This can sometimes be poorly handled by other passes as in #4610, so this PR checks for that case and drives the cell by a constant.

I haven't chosen to fully replace the cell as the logic in that function would turn e.g. |{a, 1'b1, 1'b0} into |{1'b1} rather than 1'b1, so this is in keeping for the 1'b0 case. opt_expr easily eliminates this cell due to the constant input.

Copy link
Collaborator

@widlarizer widlarizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test reproduces error described in issue, fix looks good

@widlarizer widlarizer merged commit 18459b4 into YosysHQ:main Nov 20, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants